<script>
	var url;
	$(document).ready(function(){
	
		newData = function (){
			$('#dialog').dialog({
				title: 'Tambah Data Hasil Seleksi Ujian',
				width: 925,
				height: 600,
				closed: true,
				cache: false,
				href: base_url+'hasil_seleksi/add',
				modal: true
			});
			 
			$('#dialog').dialog('open');
			url = base_url+'hasil_seleksi/save/add';
		}
		// end newData
		
		editData = function (){
			var row = $('#dg').datagrid('getSelected');
			if (row){
				$('#dialog').dialog({
					title: 'Edit Data Seleksi Ujian',
					width: 925,
					height: 600,
					closed: true,
					cache: false,
					href: base_url+'hasil_seleksi/edit/'+row.kd_hasil_seleksi,
					modal: true
				});
				
				$('#dialog').dialog('open');  
				url = base_url+'hasil_seleksi/save/edit';
			}
		}
		//end editData
		
		deleteData = function (){
			var row = $('#dg').datagrid('getSelected');
			if(row){
				if(confirm("Apakah yakin akan menghapus data '" + row.nama_hasil_seleksi + "'?")){
					var response = '';
					$.ajax({ type: "GET",
						 url: base_url+'hasil_seleksi/delete/' + row.id_hasil_seleksi,
						 async: false,
						 success : function(response){
							var response = eval('('+response+')');
							if (response.success){
								$.messager.show({
									title: 'Success',
									msg: 'Data Berhasil Dihapus'
								});
								// reload and close tab
								$('#dg').datagrid('reload');
							} else {
								$.messager.show({
									title: 'Error',
									msg: response.msg
								});
							}
						 }
					});
				}
			}
		}
		//end deleteData 
		
		saveData = function(){
			$('#form1').form('submit',{
				url: url,
				onSubmit: function(){
					return $(this).form('validate');
				},
				success: function(result){
					//alert(result);
					var result = eval('('+result+')');
					if (result.success){
						$('#dialog').dialog('close');		// close the dialog
						$('#dg').datagrid('reload');		// reload the user data
					} else {
						$.messager.show({
							title: 'Error',
							msg: result.msg
						});
					}
				}
			});
		}
		//end saveData
		
		
		$(function(){
			$('#dg').datagrid({url:"<?=base_url()?>hasil_seleksi/grid"});
		});
		
	});
</script>
<table id="dg" title="Kelola Data Peserta Hasil Seleksi" data-options="
			rownumbers:true,
			singleSelect:true,
			autoRowHeight:false,
			pagination:true,
			pageSize:30,
			fit:true,
			toolbar:'#toolbar',
			">
	<thead>
		<tr>
			<!--<th field="tahun_penerimaan" sortable="true" width="80">Tahun Penerimaan</th> -->
			<th field="no_pendaftaran" sortable="true" width="100">ID Pendaftaran</th>
			<th field="thn_penerimaan" sortable="true" width="100">Tahun Penerimaan</th>
			<th field="nama" sortable="true" width="100">Nama</th>
			<th field="nama_fakultas" sortable="true" width="100">Fakultas</th>
			<th field="nama_prodi" sortable="true" width="100">Jurusan</th>
			<!--<th field="nilai" sortable="true" width="100">Nilai</th>-->
			<th field="status" sortable="true" width="100">Hasil Seleksi</th>
			
		</tr>
	</thead>
</table>
<div id="toolbar" style="padding:5px;height:auto">
	<!--<div style="margin-bottom:5px">
		<a href="#" onclick="newData();" class="easyui-linkbutton" iconCls="icon-add" plain="true">Add</a>
		<a href="#" onclick="editData();" class="easyui-linkbutton" iconCls="icon-edit" plain="true">Edit</a>
		<a href="#" onclick="deleteData();" class="easyui-linkbutton" iconCls="icon-remove" plain="true">Delete</a>
	</div>-->
	<div>
		Tahun Penerimaan:   <select class="easyui-combobox" panelHeight="auto" style="width:100px">
								<option value="java">-- Pilih Tahun --</option>
							</select>
	
		Fakultas       :   <select class="easyui-combobox" panelHeight="auto" style="width:100px">
							<option value="java">-- Pilih Fakultas --</option>
					</select>
					
		
		Prodi       :   <select class="easyui-combobox" panelHeight="auto" style="width:100px">
							<option value="java">-- Pilih Prodi --</option>
					</select>
		<a href="#" class="easyui-linkbutton" iconCls="icon-search">Search</a>
	</div>
</div>
